package com.digitalchina.cfs.ta.hosnum.action;

import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.log4j.Logger;

import com.digitalchina.cfs.ta.hosnum.model.InoutHospitalized;
import com.digitalchina.cfs.ta.hosnum.service.HospitalizedNumberService;
import com.digitalchina.cfs.ta.hosnum.util.OptionLine;
import com.digitalchina.frame.action.BaseAction;

public class HospitalizedNumberAction extends BaseAction{

	private static final long serialVersionUID = 1L;
	private static Logger logger=Logger.getLogger(HospitalizedNumberAction.class);
	private HospitalizedNumberService hospitalizedNumberService;
	public HospitalizedNumberService getHospitalizedNumberService() {
		return hospitalizedNumberService;
	}
	public void setHospitalizedNumberService(
			HospitalizedNumberService hospitalizedNumberService) {
		this.hospitalizedNumberService = hospitalizedNumberService;
	}
	
	public String qryInOutHospitalized()throws Exception{
		String orgCode = this.servletRequest.getParameter("orgCode");
		String year = this.servletRequest.getParameter("year");
		String bz = this.servletRequest.getParameter("bz");
		List<InoutHospitalized> list = hospitalizedNumberService.qryInOutHospitalizedList(orgCode, year,bz);
		
		JSONArray json = JSONArray.fromObject(list);
		this.servletResponse.setContentType("text/json;charset=GBK");
		PrintWriter out = this.servletResponse.getWriter();
		System.out.println(json);
		out.print(json);
		out.close();
		return null;
	}
	public String qryALLInOutHospitalized()throws Exception{
		
		String year = this.servletRequest.getParameter("year");
		String bz = this.servletRequest.getParameter("bz");
		Map map = hospitalizedNumberService.qryAllInOutHospitalizedList(year, bz);
		JSONObject json = JSONObject.fromObject(map);
		this.servletResponse.setContentType("text/json;charset=GBK");
		PrintWriter out = this.servletResponse.getWriter();
		System.out.println(json);
		out.print(json);
		out.close();
		return null;
	}
	
	public String hosNumMainPage()throws Exception{
		return "hosNumMainPage";
	}
	
	
	
}


